#include "SDL/SDL.h"
#include "state.h"
#include "functions.h"
#include <iostream>
using namespace std;


/////////////////////////
// TitleScreen Functions
/////////////////////////
TitleScreen::TitleScreen()
{
	//Load the Titlescreen's resources
	background = new SDL_Surface;
	background = NULL;
	try
	{
		background = load_image("title_background.png");
		if(background == NULL)
		{
			throw 1;
		}
	}
	catch(int p)
	{
		cout << "There was an error loading the title background! Error Number:" << p << endl << flush;
	}
}

TitleScreen::~TitleScreen()
{
	//Destroy the Titlescreen's resources
	delete background;
}

void TitleScreen::handle_events()
{
	//While there's an event to handle
	while(SDL_PollEvent(&event))
	{
		if(event.type == SDL_KEYDOWN)
		{
			switch(event.key.keysym.sym)
			{
				case SDLK_ESCAPE:
					if(nextState != STATE_EXIT)
						nextState = STATE_PLAYING;
					break;
				default:
					break;
			}
		}

		//If the user has Xed out the window
		if(event.type == SDL_QUIT)
		{
			//Quit the program
			nextState = STATE_EXIT;
		}
	}
}
void TitleScreen::logic()
{

}

void TitleScreen::render()
{
	apply_surface(0, 0, background, screen);
	SDL_Flip(screen);
}


/////////////////////////
// Playing Functions
/////////////////////////
Playing::Playing()
{

}

Playing::~Playing()
{

}

void Playing::handle_events()
{

}

void Playing::logic()
{

}

void Playing::render()
{

}

/////////////////////////
// Waiting Functions
/////////////////////////
Waiting::Waiting()
{

}

Waiting::~Waiting()
{

}

void Waiting::handle_events()
{

}

void Waiting::logic()
{

}

void Waiting::render()
{

}
